//
//  SideGoodsClassesView.m
//  MobileShoppingMall
//
//  Created by 冯传昌 on 2021/4/13.
//  Copyright © 2021 冯传昌. All rights reserved.
//

#import "SideGoodsClassesView.h"

@interface SideGoodsClassesView()

@property (nonatomic,strong) NSMutableArray *sourceArr;

@property (nonatomic,strong) NSMutableArray *btnArr;

@end

@implementation SideGoodsClassesView

-(id)initWithFrame:(CGRect)frame withSourceArr:(NSArray *)arr{
    if (self == [super initWithFrame:frame]) {
        
        self.backgroundColor = UIColor.whiteColor;
        
        self.sourceArr = [NSMutableArray arrayWithArray:arr];
        self.btnArr = [NSMutableArray arrayWithArray:arr];
        
        [self initUI];
        
    }
    return self;
}

-(void)initUI{
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:self.bounds];
    self.scrollView.backgroundColor = UIColor.whiteColor;
    self.scrollView.bounces = NO;
    
    [self.scrollView setContentSize:CGSizeMake(self.width, 50*self.sourceArr.count)];
    [self addSubview:self.scrollView];
    
    for (int i = 0; i<self.sourceArr.count; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(10, 15 + i*50, 80, 20);
        [btn setTitle:self.sourceArr[i] forState:normal];
        [btn setTitleColor:UIColor.lightGrayColor forState:normal];
        [btn.titleLabel setFont:FontSet(14)];
        [btn addTarget:self action:@selector(touchClick:) forControlEvents:UIControlEventTouchUpInside];
        btn.tag = i;
        if (i==0) {
            [btn setTitleColor:UIColor.orangeColor forState:normal];
        }
        [self.scrollView addSubview:btn];
        [self.btnArr addObject:btn];
    }
    
    
}



-(void)touchClick:(UIButton *)btn{
    
}

@end




